package medium旋转图像;

import org.testng.annotations.Test;

public class Solution {
    public void rotate(int[][] matrix) {
        for (int i = 0; i < matrix.length; i++) {
            System.out.print(matrix[i][0]+"  ");
            System.out.print(matrix[i][1]+"  "  );
            System.out.print(matrix[i][2]+"  "  );
            System.out.print(matrix[i][3]+"  "  );
            System.out.println();
        }
        int[][] mirror = new int[matrix.length][matrix.length];
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix.length; j++) {
                mirror[i][matrix.length-j-1] = matrix[j][i];
            }
        }
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix.length; j++) {
                matrix[i][j] = mirror[i][j];
            }
        }
        for (int i = 0; i < matrix.length; i++) {
            System.out.print(matrix[i][0]+"  "  );
            System.out.print(matrix[i][1]+"  "  );
            System.out.print(matrix[i][2]+"  "  );
            System.out.print(matrix[i][3]+"  "  );
            System.out.println();
        }
    }
    @Test
    public void test(){
        int[][] num = {{1,2,3,4}, {5,6,7,8},{9,10,11,12},{13,14,15,16}};
        rotate(num);
    }
}
